<?php

class Ialbum_Widget_PhotosOfUsersController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
  	$this->getElement()->removeDecorator('Title');
    // Don't render this if not authorized
    $viewer = Engine_Api::_()->user()->getViewer();
    if( !Engine_Api::_()->core()->hasSubject() ) {
      return $this->setNoRender();
    }      
    $front_controller = Zend_Controller_Front::getInstance ();
    $type = $front_controller->getRequest()->getParam('type', '');  
 	$subject = $front_controller->getRequest()->getParam('subject', '');
 	if($type == 'viewall' && $subject == 'albums'){
 		return $this->setNoRender();
 	}
	$subject =  Engine_Api::_()->core()->getSubject();
	$this->view->paginator = $paginator =  Engine_Api::_()->ialbum()->getFreindTaggedPhoto(array($subject->getIdentity()));
    $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 8));
    $paginator->setCurrentPageNumber($this->_getParam('page', 1));
    $this->view->isAjax = $isAjax = $this->_getParam('isAjax', false);
    if($isAjax){
    	$this->getElement()->removeDecorator('Title');
    	$this->getElement()->removeDecorator('Container');
    }
//	if ($paginator->count() <= 0) return $this->setNoRender();
  }
}